class Solution:
    def firstUniqChar(self, s: str) -> int:
        hashMap={}
        for i in s:
            if i not in hashMap:
                hashMap[i]=1
            else:
                hashMap[i]+=1
        for key,v in hashMap.items():
            if v==1:
                return s.index(key)
        else:
            return -1

ans=Solution().firstUniqChar("loveleetcode")
print(ans)